package com.rem.hutool.my2Convert;

import cn.hutool.core.convert.Converter;
import cn.hutool.core.convert.ConverterRegistry;

/**
 * 自定义转换器
 *
 * @author Rem
 * @date 2020-08-18
 */

public class MyConvent {

    public static void main(String[] args) {
        int a = 3423;
        ConverterRegistry converterRegistry = ConverterRegistry.getInstance();
        String result = converterRegistry.convert(String.class, a);
        System.err.println(result);


        CustomConverter customConverter = new CustomConverter();
        Long l=111L;
        String convert = customConverter.convert(l, null);
        System.err.println(convert);


    }


    /**
     * 注册转换器
     */
    public static class CustomConverter implements Converter<String> {
        @Override
        public String convert(Object value, String defaultValue) throws IllegalArgumentException {
            return "Custom: " + value.toString();
        }
    }
}
